﻿@{
    ViewBag.Title = "UpdateState";
    Layout = "~/Views/Shared/_Form.cshtml";
}

<script>
    var keyValue = request('keyValue');
    var state = "";
    var _Id = "";
    $(function () {
        //当前状态
        $("#State").ComboBox({
            data: [{ "key": 0, "value": "准备房" }, { "key": 7, "value": "维修中" }],
            id: "key",
            text: "value",
            height: "200px",
            description: null
        });
        //获取表单
        if (!!keyValue) {
            $.SetForm({
                url: "../../ResourceManage/RS_PStructs/GetFormInfoJson",
                param: { keyValue: keyValue },
                success: function (data) {
                    if (!!data.data.AllName) {
                        allname = data.data.AllName.substring(0, data.data.AllName.indexOf('/' + data.data.Name));
                    }
                    _Id = data.model.RoomInfo.Id;
                    $("#BaseInfo").SetWebControls(data.data);
                    $("#State").ComboBoxSetValue(data.model.RoomInfo.State);
                    state = data.model.RoomInfo.State
                }
            });
        }
    })

    //保存表单
    function AcceptClick(obj) {
        if (state != 7) {
            dialogMsg('只允许修改维修中的房间！', 0);
            return false;
        }
        if ($("#State").attr("data-value") != 0) {
            dialogMsg('暂时只支持将维修中的房子改为准备房！', 0);
            return false;
        }
        $.SaveForm({
            url: "../../ResourceManage/RS_PStructs/UpdateState",
            param: {
                "keyValue": _Id, "State": $("#State").attr("data-value")
            },
            loading: "正在保存数据...",
            success: function () {
                $.currentIframe().$("#gridTable").resetSelection();
                $.currentIframe().$("#gridTable").trigger("reloadGrid");
            }
        });


    };
</script>
<div class="tab-content" style="padding-top: 15px;">
    <div style="margin-left: 10px; margin-top: 20px; margin-right: 30px;" class="tab-pane active">
        <table class="form" id="BaseInfo">
            <tr>
                <th class="formTitle">房产名称</th>
                <td class="formValue">
                    <input id="Name" type="text" class="form-control" readonly disabled />
                </td>
            </tr>
            <tr>
                <th class="formTitle">房产编号</th>
                <td class="formValue">
                    <input id="Code" type="text" class="form-control" readonly disabled />
                </td>
            </tr>
            <tr>
                <th class="formTitle">房产全称</th>
                <td class="formValue">
                    <input id="AllName" type="text" class="form-control" readonly disabled />
                </td>
            </tr>
            <tr>
                <th class="formTitle">当前状态</th>
                <td class="formValue" style="width:570px;">
                    <div id="State" type="select" class="ui-select" isvalid="yes" checkexpession="IsScript"></div>
                </td>
            </tr>
        </table>
    </div>
</div>